/*
*	Project: Aethon
*
*	File: Timer.h
*
*	Author: Jonathan Hersack
*
*	Date: 3/26/2009
*
*   Purpose: Provides a singleton timer to track time.
*/

#ifndef TIMER_H_
#define TIMER_H_

// max length is d
#define MAX_TIME 3000.0


using namespace std;

class Timer{
		
	float time;
	//singleton pattern based on http://www.inquiry.com/techtips/cpp_pro/10min/10min0200.asp
	
	protected:
	Timer()
    {
    time = 0;
    }
	Timer(const Timer&);//protect operations so instances are limited
	Timer& operator = (const Timer&);//protect operations so instances are limited
	private:
	static Timer* pinstance;
	
	public:
	static Timer* getInstanceOf();//returns instance of Timer   	
	void incrementTime();
	
	void setTime(float newTime)
	 {
     time = newTime;
     }
     
     float getTime()
	 {
           return time;
     }
     
     float getTimeLeft()
     {
           return MAX_TIME-time;
     }
     
     float getRatioTimeLeft()
     {
           float tempRatioLeft = 1.0-time/MAX_TIME;
           
           if( tempRatioLeft < 0.0 )
              tempRatioLeft = 0;
           
           return tempRatioLeft;
     }
	
};//end class

#endif //TIMER_H_

